/**
 * @file Junior.cpp
 * @author GalaktiK (jacobliu001@qq.com)
 * @version 1.0
 * @date 2020-12-25
 *
 * @copyright Copyright (c) 2020, Distributed under License GPLv2
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    for (int TC = 1; TC <= 5; TC++) {
        ll s, d, r;
        cin >> s >> d >> r;
        ll acc = 0;
        for (int i = r*(r-1)/2; i < r*(r+1)/2; i++) {
            ll p = (s + d * i);
            if (p % 9 == 0) {
                acc += 9;
            } else {
                acc += p % 9;
            }
        }
        cout << TC << ". " << acc << endl;
    }
    return 0;
}
